package xyz.zhno.project.user.web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import xyz.zhno.project.commons.core.dto.Result;

/**
 * 用户表现层
 * @author zh_o
 * @date 2020-11-01
 */
@Api(tags = "用户接口")
@RestController
public class UserController {

    @Value("${swagger.author.name}")
    private String name;

    /**
     * 根据 id 获取用户
     * @param id 传入用户id
     * @return 用户信息
     */
    @ApiOperation("根据 id 获取用户")
    @GetMapping("/user/get/{id}")
    @ApiImplicitParam(name = "id", value = "用户ID", type = "int", paramType = "path", required = true, dataType = "Integer")
    public ResponseEntity<Result> getUser(@PathVariable("id") Integer id) {
        System.out.println(1 / 0);
        return new ResponseEntity<>(
                Result.builder()
                        .code("00000")
                        .message("Success!")
                        .res("user:" + id)
                        .build(), HttpStatus.OK);
    }

}
